package concurrent.lock;

import java.util.Queue;

/**
 * Author: Jason Wu
 * Date  : 2013-11-28
 */
public class PutObjectTask implements Runnable {
    private final Queue<Integer> numberList;
    private Integer number;

    public PutObjectTask(Integer number, Queue<Integer> numberList) {
        this.number = number;
        this.numberList = numberList;
    }

    @Override
    public void run() {
        synchronized (numberList) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(String.format("add %s :%b", number, numberList.add(number)));
        }
    }
}
